package com.company.poker.channel;

import akka.actor.*;
import com.company.poker.network.NetworkManager;
import com.company.poker.network.NetworkPipelineFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Description of class.
 * Created 4/10/13 4:24 PM
 *
 * @author andrey.rodin@playtech.com
 */

public class ChannelServer {
    private static final Logger LOGGER = LoggerFactory.getLogger(ChannelServer.class);
//    private static ClientHandler clientHandler = new ClientHandler();
    public static void main(String[] args) {

        ActorSystem system = ActorSystem.create("poker");
        ClientHandler clientHandler = new ClientHandler();
        clientHandler.setSystem(system);

//        ActorRef myActor = system.actorOf(new Props(new UntypedActorFactory() {
//            @Override
//            public Actor create() {
//                return new CommunicationManager(clientHandler);
//            }
//        }), "networkManager");

        NetworkManager networkManager = new NetworkManager(args[0], Integer.valueOf(args[1]),Integer.valueOf(args[2]),Integer.valueOf(args[3]));

        ((NetworkPipelineFactory)networkManager.getPipelineFactory()).setHandler(clientHandler);

        LOGGER.debug("NetworkManager initialization... ");

        networkManager.init();
        LOGGER.debug("NetworkManager starting... ");
        networkManager.start();

//        ActorRef actorRef = system.actorFor("service/networkManager");

    }
}
